package com.wxh.jwt.repository;

import com.wxh.jwt.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * @ClassName: UserRepository
 * @Description:
 * @Author wxh
 * @Date: 2020/5/28 15:31
 * @Version V1.0.0
 * @Since 1.8
 */
public interface  UserRepository extends JpaRepository<User,String> {
    /**
     * 根据用户姓名查询用户信息(底层自动按照user_name='xxx'查询)
     * @param userName
     * @return User
     */
    @Query(value = " select u from User u where u.userName =?1")
    User findByUserName(String userName);

    /**
     *  根据用户ID查询用户信息
     * @param userId
     * @return User
     */
    @Query(value = " select u from User u where u.userId=?1")
    User findByUserId(String userId);
}
